<!DOCTYPE html><html><head><title>README</title><link href="http://www.jboss.org/jdf/stylesheets/documentation.css" rel="stylesheet"></link><link href="http://www.jboss.org/jdf/stylesheets/pygments.css" rel="stylesheet"></link></head><body>
<h1><a id="wsatsimple-wsat-wsatomictransaction-simple" class="anchor" href="#wsatsimple-wsat-wsatomictransaction-simple"><span class="anchor-icon"></span></a>wsat-simple: WS-AT (WS-AtomicTransaction) - Simple</h1>

<p>Author: Paul Robinson<br/>
Level: Intermediate<br/>
Technologies: WS-AT, JAX-WS<br/>
Summary: Deployment of a WS-AT (WS-AtomicTransaction) enabled JAX-WS Web service bundled in a WAR archive<br/>
Target Product: EAP<br/>
Product Versions: EAP 6.1, EAP 6.2<br/>
Source: <a href="https://github.com/jboss-developer/jboss-eap-quickstarts/">https://github.com/jboss-developer/jboss-eap-quickstarts/</a>  </p>

<h2><a id="what-is-it" class="anchor" href="#what-is-it"><span class="anchor-icon"></span></a>What is it?</h2>

<p>This example demonstrates the deployment of a WS-AT (WS-AtomicTransaction) enabled JAX-WS Web service bundled in a WAR archive for deployment to Red Hat JBoss Enterprise Application Platform.</p>

<p>The Web service is offered by a Restaurant for making bookings. The Service allows bookings to be made within an Atomic Transaction.</p>

<p>This example demonstrates the basics of implementing a WS-AT enabled Web service. It is beyond the scope of this quick start to demonstrate more advanced features. In particular:</p>

<ol>
<li>The Service does not implement the required hooks to support recovery in the presence of failures.</li>
<li>It also does not utilize a transactional back end resource.</li>
<li>Only one Web service participates in the protocol. As WS-AT is a 2PC coordination protocol, it is best suited to multi-participant scenarios.</li>
</ol>

<p>For a more complete example, please see the XTS demonstrator application that ships with the Narayana project: <a href="http://www.jboss.org/narayana">http://www.jboss.org/narayana</a>.</p>

<p>It is also assumed that you have an understanding of WS-AtomicTransaction. For more details, read the XTS documentation that ships with the Narayana project, which can be downloaded here: <a href="http://www.jboss.org/narayana/documentation/4_17_4_Final">http://www.jboss.org/narayana/documentation/4_17_4_Final</a>.</p>

<p>The application consists of a single JAX-WS web service that is deployed within a WAR archive. It is tested with a JBoss Arquillian enabled JUnit test.</p>

<p>When running the <code>org.jboss.as.quickstarts.wsat.simple.ClientTest#testCommit()</code> method, the following steps occur:</p>

<ol>
<li>A new Atomic Transaction (AT) is created by the client.</li>
<li>An operation on a WS-AT enabled Web service is invoked by the client.</li>
<li>The JaxWSHeaderContextProcessor in the WS Client handler chain inserts the WS-AT context into the outgoing SOAP message</li>
<li>When the service receives the SOAP request, the JaxWSHeaderContextProcessor in its handler chain inspects the WS-AT context and associates the request with this AT.</li>
<li>The Web service operation is invoked&hellip;</li>
<li>A participant is enlisted in this AT. This allows the Web Service logic to respond to protocol events, such as Commit and Rollback.</li>
<li>The service invokes the business logic. In this case, a booking is made with the restaurant.</li>
<li>The backend resource is prepared. This ensures that the Backend resource can undo or make permanent the change when told to do so by the coordinator.</li>
<li>The client can then decide to commit or rollback the AT. If the client decides to commit, the coordinator will begin the 2PC protocol. If the participant decides to rollback, all participants will be told to rollback.</li>
</ol>

<p>There is another test that shows what happens if the client decides to rollback the AT.</p>

<h2><a id="system-requirements" class="anchor" href="#system-requirements"><span class="anchor-icon"></span></a>System requirements</h2>

<p>The application this project produces is designed to be run on Red Hat JBoss Enterprise Application Platform 6.1 or later. </p>

<p>All you need to build this project is Java 6.0 (Java SDK 1.6) or later, Maven 3.0 or later.</p>

<h2><a id="configure-maven" class="anchor" href="#configure-maven"><span class="anchor-icon"></span></a>Configure Maven</h2>

<p>If you have not yet done so, you must <a href="../README.html#configure-maven">Configure Maven</a> before testing the quickstarts.</p>

<h2><a id="start-the-jboss-server-with-the-custom-options" class="anchor" href="#start-the-jboss-server-with-the-custom-options"><span class="anchor-icon"></span></a>Start the JBoss Server with the Custom Options</h2>

<p>First, edit the log level to reduce the amount of log output. This should make it easier to read the logs produced by this example. To do this add the
following logger block to the ./docs/examples/configs/standalone-xts.xml of your JBoss distribution. You should add it just bellow one of the other logger blocks.</p>
<div class="highlight"><pre>    <span class="nt">&lt;logger</span> <span class="na">category=</span><span class="s">&quot;org.apache.cxf.service.factory.ReflectionServiceFactoryBean&quot;</span><span class="nt">&gt;</span>
        <span class="nt">&lt;level</span> <span class="na">name=</span><span class="s">&quot;WARN&quot;</span><span class="nt">/&gt;</span>
    <span class="nt">&lt;/logger&gt;</span>         
</pre></div>
<p>Next you need to start JBoss EAP with the XTS sub system enabled. This is enabled through the optional server configuration <em>standalone-xts.xml</em>. To do this, run the following commands from the top-level directory of JBossAS:</p>
<div class="highlight"><pre>    <span class="n">For</span> <span class="n">Linux</span><span class="o">:</span>     <span class="p">.</span><span class="o">/</span><span class="n">bin</span><span class="o">/</span><span class="n">standalone</span><span class="p">.</span><span class="n">sh</span> <span class="o">--</span><span class="n">server</span><span class="o">-</span><span class="n">config</span><span class="o">=</span><span class="p">..</span><span class="o">/</span><span class="p">..</span><span class="o">/</span><span class="n">docs</span><span class="o">/</span><span class="n">examples</span><span class="o">/</span><span class="n">configs</span><span class="o">/</span><span class="n">standalone</span><span class="o">-</span><span class="n">xts</span><span class="p">.</span><span class="n">xml</span>
    <span class="n">For</span> <span class="n">Windows</span><span class="o">:</span>   <span class="err">\</span><span class="n">bin</span><span class="err">\</span><span class="n">standalone</span><span class="p">.</span><span class="n">bat</span> <span class="o">--</span><span class="n">server</span><span class="o">-</span><span class="n">config</span><span class="o">=</span><span class="p">..</span><span class="err">\</span><span class="p">..</span><span class="err">\</span><span class="n">docs</span><span class="err">\</span><span class="n">examples</span><span class="err">\</span><span class="n">configs</span><span class="err">\</span><span class="n">standalone</span><span class="o">-</span><span class="n">xts</span><span class="p">.</span><span class="n">xml</span>
</pre></div>
<h2><a id="run-the-arquillian-tests-" class="anchor" href="#run-the-arquillian-tests-"><span class="anchor-icon"></span></a>Run the Arquillian Tests </h2>

<p>This quickstart provides Arquillian tests. By default, these tests are configured to be skipped as Arquillian tests require the use of a container. </p>

<p><em>NOTE: The following commands assume you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See <a href="../README.html#run-the-arquillian-tests">Run the Arquillian Tests</a> for complete instructions and additional options.</em></p>

<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>Type the following command to run the test goal with the following profile activated:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">test</span> <span class="o">-</span><span class="n">Parq</span><span class="o">-</span><span class="n">jbossas</span><span class="o">-</span><span class="n">remote</span> 
</pre></div></li>
</ol>

<h2><a id="investigate-the-server-log" class="anchor" href="#investigate-the-server-log"><span class="anchor-icon"></span></a>Investigate the Server Log</h2>

<p>The following messages should appear in the server log. Note there may be other log messages interlaced between these. The messages trace the steps taken by the tests.</p>

<p>Test commit:</p>
<div class="highlight"><pre><span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">28</span><span class="o">,</span><span class="mi">208</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="n">threads</span> <span class="o">-</span> <span class="mi">14</span><span class="o">)</span> <span class="n">Starting</span> <span class="s1">&#39;testCommit&#39;</span><span class="o">.</span> <span class="n">This</span> <span class="n">test</span> <span class="n">invokes</span> <span class="n">a</span> <span class="n">WS</span> <span class="n">within</span> <span class="n">an</span> <span class="n">AT</span><span class="o">.</span> <span class="n">The</span> <span class="n">AT</span> <span class="k">is</span> <span class="n">later</span> <span class="n">committed</span><span class="o">,</span> <span class="n">which</span> <span class="n">causes</span> <span class="n">the</span> <span class="n">back</span><span class="o">-</span><span class="n">end</span> <span class="n">resource</span><span class="o">(</span><span class="n">s</span><span class="o">)</span> <span class="n">to</span> <span class="n">be</span> <span class="n">committed</span><span class="o">.</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">28</span><span class="o">,</span><span class="mi">209</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="n">threads</span> <span class="o">-</span> <span class="mi">14</span><span class="o">)</span> <span class="o">[</span><span class="n">CLIENT</span><span class="o">]</span> <span class="n">Creating</span> <span class="n">a</span> <span class="k">new</span> <span class="n">WS</span><span class="o">-</span><span class="n">AT</span> <span class="n">User</span> <span class="n">Transaction</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">28</span><span class="o">,</span><span class="mi">209</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="n">threads</span> <span class="o">-</span> <span class="mi">14</span><span class="o">)</span> <span class="o">[</span><span class="n">CLIENT</span><span class="o">]</span> <span class="n">Beginning</span> <span class="n">Atomic</span> <span class="n">Transaction</span> <span class="o">(</span><span class="n">All</span> <span class="n">calls</span> <span class="n">to</span> <span class="n">Web</span> <span class="n">services</span> <span class="n">that</span> <span class="n">support</span> <span class="n">WS</span><span class="o">-</span><span class="n">AT</span> <span class="n">wil</span> <span class="n">be</span> <span class="n">included</span> <span class="k">in</span> <span class="k">this</span> <span class="n">transaction</span><span class="o">)</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">28</span><span class="o">,</span><span class="mi">532</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="n">threads</span> <span class="o">-</span> <span class="mi">14</span><span class="o">)</span> <span class="o">[</span><span class="n">CLIENT</span><span class="o">]</span> <span class="n">invoking</span> <span class="n">makeBooking</span><span class="o">()</span> <span class="n">on</span> <span class="n">WS</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">29</span><span class="o">,</span><span class="mi">168</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">http</span><span class="o">-</span><span class="n">localhost</span><span class="o">-</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="o">-</span><span class="mi">8080</span><span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">Restaurant</span> <span class="n">service</span> <span class="n">invoked</span> <span class="n">to</span> <span class="n">make</span> <span class="n">a</span> <span class="n">booking</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">29</span><span class="o">,</span><span class="mi">168</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">http</span><span class="o">-</span><span class="n">localhost</span><span class="o">-</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="o">-</span><span class="mi">8080</span><span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">Enlisting</span> <span class="n">a</span> <span class="n">Durable2PC</span> <span class="n">participant</span> <span class="n">into</span> <span class="n">the</span> <span class="n">AT</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">29</span><span class="o">,</span><span class="mi">410</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">http</span><span class="o">-</span><span class="n">localhost</span><span class="o">-</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="o">-</span><span class="mi">8080</span><span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">Invoking</span> <span class="n">the</span> <span class="n">back</span><span class="o">-</span><span class="n">end</span> <span class="n">business</span> <span class="n">logic</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">29</span><span class="o">,</span><span class="mi">410</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">http</span><span class="o">-</span><span class="n">localhost</span><span class="o">-</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="o">-</span><span class="mi">8080</span><span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">makeBooking</span> <span class="n">called</span> <span class="n">on</span> <span class="n">backend</span> <span class="n">resource</span><span class="o">.</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">29</span><span class="o">,</span><span class="mi">411</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="n">threads</span> <span class="o">-</span> <span class="mi">14</span><span class="o">)</span> <span class="o">[</span><span class="n">CLIENT</span><span class="o">]</span> <span class="n">committing</span> <span class="n">Atomic</span> <span class="n">Transaction</span> <span class="o">(</span><span class="n">This</span> <span class="n">will</span> <span class="n">cause</span> <span class="n">the</span> <span class="n">AT</span> <span class="n">to</span> <span class="n">complete</span> <span class="n">successfully</span><span class="o">)</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">29</span><span class="o">,</span><span class="mi">974</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">TaskWorker</span><span class="o">-</span><span class="mi">3</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">Prepare</span> <span class="n">called</span> <span class="n">on</span> <span class="n">participant</span><span class="o">,</span> <span class="n">about</span> <span class="n">to</span> <span class="n">prepare</span> <span class="n">the</span> <span class="n">back</span><span class="o">-</span><span class="n">end</span> <span class="n">resource</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">29</span><span class="o">,</span><span class="mi">974</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">TaskWorker</span><span class="o">-</span><span class="mi">3</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">prepare</span> <span class="n">called</span> <span class="n">on</span> <span class="n">backend</span> <span class="n">resource</span><span class="o">.</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">29</span><span class="o">,</span><span class="mi">974</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">TaskWorker</span><span class="o">-</span><span class="mi">3</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">back</span><span class="o">-</span><span class="n">end</span> <span class="n">resource</span> <span class="n">prepared</span><span class="o">,</span> <span class="n">participant</span> <span class="n">votes</span> <span class="n">prepared</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">30</span><span class="o">,</span><span class="mi">560</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">TaskWorker</span><span class="o">-</span><span class="mi">3</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">all</span> <span class="n">participants</span> <span class="n">voted</span> <span class="s1">&#39;prepared&#39;</span><span class="o">,</span> <span class="n">so</span> <span class="n">coordinator</span> <span class="n">tells</span> <span class="n">the</span> <span class="n">participant</span> <span class="n">to</span> <span class="n">commit</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">30</span><span class="o">,</span><span class="mi">560</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">TaskWorker</span><span class="o">-</span><span class="mi">3</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">commit</span> <span class="n">called</span> <span class="n">on</span> <span class="n">backend</span> <span class="n">resource</span><span class="o">.</span>
</pre></div>
<p>Test rollback:</p>
<div class="highlight"><pre><span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">31</span><span class="o">,</span><span class="mi">163</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="n">threads</span> <span class="o">-</span> <span class="mi">13</span><span class="o">)</span> <span class="n">Starting</span> <span class="s1">&#39;testRollback&#39;</span><span class="o">.</span> <span class="n">This</span> <span class="n">test</span> <span class="n">invokes</span> <span class="n">a</span> <span class="n">WS</span> <span class="n">within</span> <span class="n">an</span> <span class="n">AT</span><span class="o">.</span> <span class="n">The</span> <span class="n">AT</span> <span class="k">is</span> <span class="n">later</span> <span class="n">rolled</span> <span class="n">back</span><span class="o">,</span> <span class="n">which</span> <span class="n">causes</span> <span class="n">the</span> <span class="n">back</span><span class="o">-</span><span class="n">end</span> <span class="n">resource</span><span class="o">(</span><span class="n">s</span><span class="o">)</span> <span class="n">to</span> <span class="n">be</span> <span class="n">rolled</span> <span class="n">back</span><span class="o">.</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">31</span><span class="o">,</span><span class="mi">163</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="n">threads</span> <span class="o">-</span> <span class="mi">13</span><span class="o">)</span> <span class="o">[</span><span class="n">CLIENT</span><span class="o">]</span> <span class="n">Creating</span> <span class="n">a</span> <span class="k">new</span> <span class="n">WS</span><span class="o">-</span><span class="n">AT</span> <span class="n">User</span> <span class="n">Transaction</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">31</span><span class="o">,</span><span class="mi">164</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="n">threads</span> <span class="o">-</span> <span class="mi">13</span><span class="o">)</span> <span class="o">[</span><span class="n">CLIENT</span><span class="o">]</span> <span class="n">Beginning</span> <span class="n">Atomic</span> <span class="n">Transaction</span> <span class="o">(</span><span class="n">All</span> <span class="n">calls</span> <span class="n">to</span> <span class="n">Web</span> <span class="n">services</span> <span class="n">that</span> <span class="n">support</span> <span class="n">WS</span><span class="o">-</span><span class="n">AT</span> <span class="n">wil</span> <span class="n">be</span> <span class="n">included</span> <span class="k">in</span> <span class="k">this</span> <span class="n">transaction</span><span class="o">)</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">31</span><span class="o">,</span><span class="mi">461</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="n">threads</span> <span class="o">-</span> <span class="mi">13</span><span class="o">)</span> <span class="o">[</span><span class="n">CLIENT</span><span class="o">]</span> <span class="n">invoking</span> <span class="n">makeBooking</span><span class="o">()</span> <span class="n">on</span> <span class="n">WS</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">32</span><span class="o">,</span><span class="mi">094</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">http</span><span class="o">-</span><span class="n">localhost</span><span class="o">-</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="o">-</span><span class="mi">8080</span><span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">Restaurant</span> <span class="n">service</span> <span class="n">invoked</span> <span class="n">to</span> <span class="n">make</span> <span class="n">a</span> <span class="n">booking</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">32</span><span class="o">,</span><span class="mi">094</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">http</span><span class="o">-</span><span class="n">localhost</span><span class="o">-</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="o">-</span><span class="mi">8080</span><span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">Enlisting</span> <span class="n">a</span> <span class="n">Durable2PC</span> <span class="n">participant</span> <span class="n">into</span> <span class="n">the</span> <span class="n">AT</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">32</span><span class="o">,</span><span class="mi">297</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">http</span><span class="o">-</span><span class="n">localhost</span><span class="o">-</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="o">-</span><span class="mi">8080</span><span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">Invoking</span> <span class="n">the</span> <span class="n">back</span><span class="o">-</span><span class="n">end</span> <span class="n">business</span> <span class="n">logic</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">32</span><span class="o">,</span><span class="mi">322</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">http</span><span class="o">-</span><span class="n">localhost</span><span class="o">-</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="o">-</span><span class="mi">8080</span><span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">makeBooking</span> <span class="n">called</span> <span class="n">on</span> <span class="n">backend</span> <span class="n">resource</span><span class="o">.</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">32</span><span class="o">,</span><span class="mi">324</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">management</span><span class="o">-</span><span class="n">handler</span><span class="o">-</span><span class="n">threads</span> <span class="o">-</span> <span class="mi">13</span><span class="o">)</span> <span class="o">[</span><span class="n">CLIENT</span><span class="o">]</span> <span class="n">rolling</span> <span class="n">back</span> <span class="n">Atomic</span> <span class="n">Transaction</span> <span class="o">(</span><span class="n">This</span> <span class="n">will</span> <span class="n">cause</span> <span class="n">the</span> <span class="n">AT</span> <span class="n">and</span> <span class="n">thus</span> <span class="n">the</span> <span class="n">enlisted</span> <span class="n">back</span><span class="o">-</span><span class="n">end</span> <span class="n">resources</span> <span class="n">to</span> <span class="n">rollback</span><span class="o">)</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">32</span><span class="o">,</span><span class="mi">818</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">TaskWorker</span><span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">one</span> <span class="n">or</span> <span class="n">more</span> <span class="n">participants</span> <span class="n">voted</span> <span class="s1">&#39;aborted&#39;</span> <span class="n">or</span> <span class="n">a</span> <span class="n">failure</span> <span class="n">occurred</span><span class="o">,</span> <span class="n">so</span> <span class="n">coordinator</span> <span class="n">tells</span> <span class="n">the</span> <span class="n">participant</span> <span class="n">to</span> <span class="n">rollback</span>
<span class="mi">14</span><span class="o">:</span><span class="mi">06</span><span class="o">:</span><span class="mi">32</span><span class="o">,</span><span class="mi">818</span> <span class="n">INFO</span>  <span class="o">[</span><span class="n">stdout</span><span class="o">]</span> <span class="o">(</span><span class="n">TaskWorker</span><span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="o">[</span><span class="n">SERVICE</span><span class="o">]</span> <span class="n">rollback</span> <span class="n">called</span> <span class="n">on</span> <span class="n">backend</span> <span class="n">resource</span><span class="o">.</span>
</pre></div>
<h2><a id="run-the-quickstart-in-jboss-developer-studio-or-eclipse" class="anchor" href="#run-the-quickstart-in-jboss-developer-studio-or-eclipse"><span class="anchor-icon"></span></a>Run the Quickstart in JBoss Developer Studio or Eclipse</h2>

<p>You can also start the server and deploy the quickstarts from Eclipse using JBoss tools. For more information, see <a href="../README.html#use-jboss-developer-studio-or-eclipse-to-run-the-quickstarts">Use JBoss Developer Studio or Eclipse to Run the Quickstarts</a> </p>

<h2><a id="debug-the-application" class="anchor" href="#debug-the-application"><span class="anchor-icon"></span></a>Debug the Application</h2>

<p>If you want to debug the source code or look at the Javadocs of any library in the project, run either of the following commands to pull them into your local repository. The IDE should then detect them.</p>
<div class="highlight"><pre>    <span class="n">mvn</span> <span class="n">dependency</span><span class="o">:</span><span class="n">sources</span>
    <span class="n">mvn</span> <span class="n">dependency</span><span class="o">:</span><span class="n">resolve</span> <span class="o">-</span><span class="n">Dclassifier</span><span class="o">=</span><span class="n">javadoc</span>
</pre></div>
<h2><a id="build-and-deploy-the-quickstart-to-openshift" class="anchor" href="#build-and-deploy-the-quickstart-to-openshift"><span class="anchor-icon"></span></a>Build and Deploy the Quickstart - to OpenShift</h2>

<h3><a id="create-an-openshift-express-account-and-domain" class="anchor" href="#create-an-openshift-express-account-and-domain"><span class="anchor-icon"></span></a>Create an OpenShift Express Account and Domain</h3>

<p>If you do not yet have an OpenShift account and domain, <a href="https://openshift.redhat.com/app/login">Sign in to OpenShift</a> to create the account and domain. <a href="https://www.openshift.com/get-started">Get Started with OpenShift</a> will show you how to install the OpenShift Express command line interface.</p>

<h3><a id="create-the-openshift-application" class="anchor" href="#create-the-openshift-application"><span class="anchor-icon"></span></a>Create the OpenShift Application</h3>

<p>Note that we use <code>USER_DOMAIN_NAME</code> for these examples. You need to substitute it with your own OpenShift account user name.</p>

<p>Open a shell command prompt and change to a directory of your choice. Enter the following command to create a JBoss EAP 6 application:</p>
<div class="highlight"><pre><span class="n">rhc</span> <span class="n">app</span> <span class="n">create</span> <span class="o">-</span><span class="n">a</span> <span class="n">wsatsimple</span> <span class="o">-</span><span class="n">t</span> <span class="n">jbosseap</span><span class="o">-</span><span class="mi">6</span>
</pre></div>
<p><em>NOTE</em>: The domain name for this application will be <code>wsatsimple-YOUR_DOMAIN_NAME.rhcloud.com</code>. Be sure to replace <code>YOUR_DOMAIN_NAME</code> with your own OpenShift account user name.</p>

<p>This command creates an OpenShift application called <code>wsatsimple</code> and will run the application inside the <code>jbosseap-6</code> container. You should see some output similar to the following:</p>
<div class="highlight"><pre><span class="gh">Application Options</span>
<span class="gh">-------------------</span>
  Namespace:  YOUR_DOMAIN_NAME
  Cartridges: jbosseap-6 (addtl. costs may apply)
  Gear Size:  default
  Scaling:    no

Creating application &#39;wsatsimple&#39; ... done

Waiting for your DNS name to be available ... done

Cloning into &#39;wsatsimple&#39;...
Warning: Permanently added the RSA host key for IP address &#39;54.237.58.0&#39; to the list of known hosts.

Your application &#39;wsatsimple&#39; is now available.

  URL:        http://wsatsimple-YOUR_DOMAIN_NAME.rhcloud.com/
  SSH to:     52864af85973ca430200006f@wsatsimple-YOUR_DOMAIN_NAME.rhcloud.com
  Git remote: ssh://52864af85973ca430200006f@wsatsimple-YOUR_DOMAIN_NAME.rhcloud.com/~/git/wsatsimple.git/
  Cloned to:  CURRENT_DIRECTORY/wsatsimple

Run &#39;rhc show-app wsatsimple&#39; for more details about your app.
</pre></div>
<p>The create command creates a git repository in the current directory with the same name as the application, in this case, <code>wsatsimple</code>. Notice that the output also reports the URL at which the application can be accessed. Make sure it is available by typing the published url <a href="http://wsatsimple-YOUR_DOMAIN_NAME.rhcloud.com/">http://wsatsimple-YOUR_DOMAIN_NAME.rhcloud.com/</a> into a browser or use command line tools such as curl or wget. Be sure to replace <code>YOUR_DOMAIN_NAME</code> with your OpenShift account domain name.</p>

<h3><a id="migrate-the-quickstart-source" class="anchor" href="#migrate-the-quickstart-source"><span class="anchor-icon"></span></a>Migrate the Quickstart Source</h3>

<p>Now that you have confirmed it is working you can migrate the quickstart source. You do not need the generated default application, so navigate to the new git repository directory and tell git to remove the source and pom files:</p>
<div class="highlight"><pre>    <span class="n">cd</span> <span class="n">wsatsimple</span>
    <span class="n">git</span> <span class="n">rm</span> <span class="o">-</span><span class="n">r</span> <span class="n">src</span> <span class="n">pom</span><span class="p">.</span><span class="n">xml</span>
</pre></div>
<p>Copy the source for the <code>wsat-simple</code> quickstart into this new git repo:</p>
<div class="highlight"><pre>    <span class="nx">cp</span> <span class="na">-r</span> <span class="o">&lt;</span><span class="nx">quickstarts</span><span class="o">&gt;/</span><span class="nx">wsat</span><span class="na">-simple</span><span class="p">/</span><span class="nb">src</span> <span class="nx">.</span>
    <span class="nx">cp</span> <span class="o">&lt;</span><span class="nx">quickstarts</span><span class="o">&gt;/</span><span class="nx">wsat</span><span class="na">-simple</span><span class="p">/</span><span class="nx">pom.xml</span> <span class="nx">.</span>
</pre></div>
<h3><a id="configure-the-openshift-server" class="anchor" href="#configure-the-openshift-server"><span class="anchor-icon"></span></a>Configure the OpenShift Server</h3>

<p>Openshift does not have Web services or WS-AT enabled by default, so we need to modify the server configuration. To do this:</p>

<ol>
<li>Open the hidden <code>.openshift/config/standalone.xml</code> file in an editor. </li>
<li><p>If the following extensions do not exist, add them under the <code>&lt;extensions&gt;</code> element: </p>
<div class="highlight"><pre><span class="o">&lt;</span><span class="n">extension</span> <span class="n">module</span><span class="o">=</span><span class="s">&quot;org.jboss.as.webservices&quot;</span><span class="o">/&gt;</span>
<span class="o">&lt;</span><span class="n">extension</span> <span class="n">module</span><span class="o">=</span><span class="s">&quot;org.jboss.as.xts&quot;</span><span class="o">/&gt;</span>
</pre></div></li>
<li><p>If the <code>jmx</code> subsystem is not configured under the <code>&lt;profile&gt;</code> element, copy the following under the <code>&lt;profile&gt;</code> element to enable and configure JMX:</p>
<div class="highlight"><pre><span class="nt">&lt;subsystem</span> <span class="na">xmlns=</span><span class="s">&quot;urn:jboss:domain:jmx:1.1&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;show-model</span> <span class="na">value=</span><span class="s">&quot;true&quot;</span><span class="nt">/&gt;</span>
    <span class="nt">&lt;remoting-connector/&gt;</span>
<span class="nt">&lt;/subsystem&gt;</span>
</pre></div></li>
<li><p>If the <code>webservices</code> subsystem is not configured under the <code>&lt;profile&gt;</code> element, copy the following under the <code>&lt;profile&gt;</code> element to enable and configure Web Services:</p>
<div class="highlight"><pre><span class="nt">&lt;subsystem</span> <span class="na">xmlns=</span><span class="s">&quot;urn:jboss:domain:webservices:1.1&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;modify</span><span class="err">-wsdl-address</span><span class="nt">&gt;</span>true<span class="nt">&lt;/modify-wsdl-address&gt;</span>
    <span class="nt">&lt;wsdl</span><span class="err">-host</span><span class="nt">&gt;</span><span class="cp">${</span><span class="n">env</span><span class="o">.</span><span class="n">OPENSHIFT_APP_DNS</span><span class="cp">}</span><span class="nt">&lt;/wsdl-host&gt;</span>
    <span class="nt">&lt;wsdl</span><span class="err">-port</span><span class="nt">&gt;</span>80<span class="nt">&lt;/wsdl-port&gt;</span>
    <span class="nt">&lt;endpoint</span><span class="err">-config</span> <span class="na">name=</span><span class="s">&quot;Standard-Endpoint-Config&quot;/</span><span class="nt">&gt;</span>
    <span class="nt">&lt;endpoint</span><span class="err">-config</span> <span class="na">name=</span><span class="s">&quot;Recording-Endpoint-Config&quot;</span><span class="nt">&gt;</span>
        <span class="nt">&lt;pre</span><span class="err">-handler-chain</span> <span class="na">name=</span><span class="s">&quot;recording-handlers&quot;</span> <span class="na">protocol-bindings=</span><span class="s">&quot;##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM&quot;</span><span class="nt">&gt;</span>
            <span class="nt">&lt;handler</span> <span class="na">name=</span><span class="s">&quot;RecordingHandler&quot;</span> <span class="na">class=</span><span class="s">&quot;org.jboss.ws.common.invocation.RecordingServerHandler&quot;/</span><span class="nt">&gt;</span>
        <span class="nt">&lt;/pre-handler-chain&gt;</span>
    <span class="nt">&lt;/endpoint-config&gt;</span>
<span class="nt">&lt;/subsystem&gt;</span>
</pre></div></li>
<li><p>If the <code>xts</code> subsystem is not configured under the <code>&lt;profile&gt;</code> element, copy the following under the <code>&lt;profile&gt;</code> element to enable and configure XTS:</p>
<div class="highlight"><pre><span class="nt">&lt;subsystem</span> <span class="na">xmlns=</span><span class="s">&quot;urn:jboss:domain:xts:1.0&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;xts</span><span class="err">-environment</span> <span class="na">url=</span><span class="s">&quot;http://</span><span class="cp">${</span><span class="n">env</span><span class="o">.</span><span class="n">OPENSHIFT_JBOSSEAP_IP</span><span class="cp">}</span><span class="s">:8080/ws-c11/ActivationService&quot;/</span><span class="nt">&gt;</span>
<span class="nt">&lt;/subsystem&gt;</span>
</pre></div></li>
<li><p>To reduce the amount of logging and make it easier to read the logs produced by this quickstart, edit the log level by adding the following block just below the other blocks:</p>
<div class="highlight"><pre><span class="nt">&lt;logger</span> <span class="na">category=</span><span class="s">&quot;org.apache.cxf.service.factory.ReflectionServiceFactoryBean&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;level</span> <span class="na">name=</span><span class="s">&quot;WARN&quot;</span><span class="nt">/&gt;</span>
<span class="nt">&lt;/logger&gt;</span>
</pre></div></li>
</ol>

<p>The <code>.openshift/config/standalone.xml</code> is now ready, so save it and exit your editor.</p>

<h3><a id="deploy-the-openshift-application" class="anchor" href="#deploy-the-openshift-application"><span class="anchor-icon"></span></a>Deploy the OpenShift Application</h3>

<p>You can now deploy the changes to your OpenShift application using git as follows:</p>
<div class="highlight"><pre>    <span class="n">git</span> <span class="n">add</span> <span class="n">src</span> <span class="n">pom</span><span class="p">.</span><span class="n">xml</span> <span class="p">.</span><span class="n">openshift</span><span class="o">/</span><span class="n">config</span><span class="o">/</span><span class="n">standalone</span><span class="p">.</span><span class="n">xml</span>
    <span class="n">git</span> <span class="n">commit</span> <span class="o">-</span><span class="n">m</span> <span class="s">&quot;wsat-simple quickstart on OpenShift&quot;</span>
    <span class="n">git</span> <span class="n">push</span>
</pre></div>
<p>OpenShift will build the application using Maven, and deploy it to JBoss EAP. If successful, you should see output similar to:</p>
<div class="highlight"><pre><span class="nl">remote:</span> <span class="p">[</span><span class="n">INFO</span><span class="p">]</span> <span class="o">------------------------------------------------------------------------</span>
<span class="nl">remote:</span> <span class="p">[</span><span class="n">INFO</span><span class="p">]</span> <span class="n">BUILD</span> <span class="n">SUCCESS</span>
<span class="nl">remote:</span> <span class="p">[</span><span class="n">INFO</span><span class="p">]</span> <span class="o">------------------------------------------------------------------------</span>
<span class="nl">remote:</span> <span class="p">[</span><span class="n">INFO</span><span class="p">]</span> <span class="n">Total</span> <span class="n">time</span><span class="o">:</span> <span class="mf">19.991</span><span class="n">s</span>
<span class="nl">remote:</span> <span class="p">[</span><span class="n">INFO</span><span class="p">]</span> <span class="n">Finished</span> <span class="n">at</span><span class="o">:</span> <span class="n">Wed</span> <span class="n">Mar</span> <span class="mo">07</span> <span class="mi">12</span><span class="o">:</span><span class="mi">48</span><span class="o">:</span><span class="mi">15</span> <span class="n">EST</span> <span class="mi">2012</span>
<span class="nl">remote:</span> <span class="p">[</span><span class="n">INFO</span><span class="p">]</span> <span class="n">Final</span> <span class="n">Memory</span><span class="o">:</span> <span class="mi">8</span><span class="n">M</span><span class="o">/</span><span class="mi">168</span><span class="n">M</span>
<span class="nl">remote:</span> <span class="p">[</span><span class="n">INFO</span><span class="p">]</span> <span class="o">------------------------------------------------------------------------</span>
<span class="nl">remote:</span> <span class="n">Running</span> <span class="p">.</span><span class="n">openshift</span><span class="o">/</span><span class="n">action_hooks</span><span class="o">/</span><span class="n">build</span>
<span class="nl">remote:</span> <span class="n">Emptying</span> <span class="n">tmp</span> <span class="n">dir</span><span class="o">:</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">libra</span><span class="o">/</span><span class="mf">1e63</span><span class="n">c17c2dd94a329f21555a33dc617d</span><span class="o">/</span><span class="n">wsatsimple</span><span class="o">/</span><span class="n">jbossas</span><span class="o">-</span><span class="mi">7</span><span class="o">/</span><span class="n">standalone</span><span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">vfs</span>
<span class="nl">remote:</span> <span class="n">Emptying</span> <span class="n">tmp</span> <span class="n">dir</span><span class="o">:</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">libra</span><span class="o">/</span><span class="mf">1e63</span><span class="n">c17c2dd94a329f21555a33dc617d</span><span class="o">/</span><span class="n">wsatsimple</span><span class="o">/</span><span class="n">jbossas</span><span class="o">-</span><span class="mi">7</span><span class="o">/</span><span class="n">standalone</span><span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">work</span>
<span class="nl">remote:</span> <span class="n">Running</span> <span class="p">.</span><span class="n">openshift</span><span class="o">/</span><span class="n">action_hooks</span><span class="o">/</span><span class="n">deploy</span>
<span class="nl">remote:</span> <span class="n">Starting</span> <span class="n">application</span><span class="p">...</span>
<span class="nl">remote:</span> <span class="n">Done</span>
<span class="nl">remote:</span> <span class="n">Running</span> <span class="p">.</span><span class="n">openshift</span><span class="o">/</span><span class="n">action_hooks</span><span class="o">/</span><span class="n">post_deploy</span>
<span class="n">To</span> <span class="n">ssh</span><span class="o">:</span><span class="c1">//1e63c17c2dd94a329f21555a33dc617d@wsatsimple-YOUR_DOMAIN_NAME.rhcloud.com/~/git/wsatsimple.git/</span>
   <span class="n">e6f80bd</span><span class="p">.</span><span class="mf">.63504</span><span class="n">b9</span>  <span class="n">master</span> <span class="o">-&gt;</span> <span class="n">master</span>
</pre></div>
<p>Note that the <code>openshift</code> profile in the <code>pom.xml</code> file is activated by OpenShift. This causes the WAR built by OpenShift to be copied to the <code>deployments/</code> directory and deployed without a context path.</p>

<h3><a id="test-the-openshift-application" class="anchor" href="#test-the-openshift-application"><span class="anchor-icon"></span></a>Test the OpenShift Application</h3>

<p>Now you will start to tail the log files of the server. To do this run the following command, remembering to replace the application name and login id.</p>
<div class="highlight"><pre>    <span class="n">rhc</span> <span class="n">tail</span> <span class="n">wsatsimple</span>
</pre></div>
<p>Once the app is deployed, you can test the application by accessing the following URL either via a browser or using tools such as curl or wget. Be sure to replace the <code>YOUR_DOMAIN_NAME</code> in the URL with your OpenShift account domain name.</p>
<div class="highlight"><pre><span class="nl">http:</span><span class="c1">//wsatsimple-YOUR_DOMAIN_NAME.rhcloud.com/WSATSimpleServletClient</span>
</pre></div>
<p>If the application has run successfully you should see some output in the browser. You should also see some output on the server log, similar to the output from the &ldquo;Test commit&rdquo; test above.</p>

<p>You can use the OpenShift command line tools or the OpenShift web console to discover and control the application.</p>

<h3><a id="delete-the-openshift-application" class="anchor" href="#delete-the-openshift-application"><span class="anchor-icon"></span></a>Delete the OpenShift Application</h3>

<p>When you are finished with the application you can delete it from OpenShift as follows:</p>
<div class="highlight"><pre>    <span class="n">rhc</span> <span class="n">app</span><span class="o">-</span><span class="n">delete</span> <span class="o">-</span><span class="n">a</span> <span class="n">wsatsimple</span>
</pre></div>
<p><em>Note</em>: There is a limit to the number of applications you can deploy concurrently to OpenShift. If the <code>rhc app create</code> command returns an error indicating you have reached that limit, you must delete an existing application before you continue. </p>

<ul>
<li>To view the list of your OpenShift applications, type: <code>rhc domain show</code></li>
<li>To delete an application from OpenShift, type the following, substituting the application name you want to delete: <code>rhc app-delete -a APPLICATION_NAME_TO_DELETE</code></li>
</ul>
</body></html>
